<template>
	<view class="tabbar" :style="{'padding-bottom': (paddingBottomHeight+10) + 'rpx'}">
		<image class="tabbar_bg" src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/tab_bg.png" mode=""></image>
		<view class="tabbar-item" :class="index==2?'tabbar-item1':''"
				v-for="(item, index) in list" 
				:key="index" 
				@click="tabbarChange(item.path)"
		>
			<view  class="item-name" :class="{'tabbarActive': current == index}" v-if="item.text">{{item.text}}</view>
			<image  v-if='index!=2 && current == index' class="item-img" :src="item.icon_a"></image>
			<image  v-if='index!=2 && current != index' class="item-img" :src="item.icon"></image>
			<view class="item-img1" v-if='index==2' >
				<image  class="item-img item-img2" v-if='index==2' :src="item.icon"></image>
			</view>
		</view>
	</view>
</template>
<script>

export default {
    props: {
        current: String
    },
    data() {
        return {
            paddingBottomHeight: 0,  //苹果X以上手机底部适配高度
            list: [{
                    text: '首页',  
                    icon: 'https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/4/2020/09/zt.png',  //未选中图标
                    icon_a: '../static/image/tabbar/icon1.png', //选中图片
                    path: "/pages/index/index",
                },{
                    text: '地图',
                    icon: 'https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/4/2020/09/cyl.png',
										icon_a: '../static/image/tabbar/icon2.png', //选中图片
                    path: "/pages/mapPage/mapPage",
                }
                ,{
                    text: '',
										icon: '../static/image/tabbar/icon3.png', //选中图片
										icon_a: '../static/image/tabbar/icon3.png', //选中图片
                    path: '/pages/fb/fb', 
                },{
                    text: '推送',
                    icon: 'https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/4/2020/09/xm.png',
                    icon_a: '../static/image/tabbar/icon4.png', //选中图片
                    path: "/pages/xxList/xxList",
                },{
                    text: '我的',
                    icon: 'https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/4/2020/09/my.png',
										icon_a: '../static/image/tabbar/icon5.png', //选中图片
                    path: "/pages/my/my",
                },
            ]
        };
    },
    created() {
        let that = this;
        uni.getSystemInfo({
            success: function (res) {
                let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
                model.forEach(item => {
                    //适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
                    if(res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
                        that.paddingBottomHeight = 40;
                    }
                })
            }
        });
    },
    watch: {
        
    },
    methods: {
        tabbarChange(path) {
					uni.switchTab({
							url: path
					})
					// uni.navigateTo({
					// 	url: path
					// })
        }
    }
};
</script>

<style lang="scss" scoped>
    .tabbarActive{
        color: #C79D5E !important;
    }
		.tabbar_bg{
			width: 100%;
			height: 80px;
			top: -30px;
			left: 1px;
			position: absolute;
		}
    .tabbar{
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100rpx;
				// background: url(../static/image/tab_bg.png) no-repeat;
				// background-size:100% 100% ;
        background-color: #fff;
				background-size: 100%;
        display: flex;
        justify-content: space-around;
				z-index: 1000;
        // align-items: center;
        .tabbar-item{
            display: flex;
            flex-direction: column-reverse;
            align-items: center;
						margin-bottom: 10rpx;
						width: 19.5%;
						position: relative;
						z-index: 1;
            .item-img{
                width: 40rpx;
                height: 40rpx;
                margin-bottom: 4rpx;
								z-index: 1;
            }
						.item-img1{
								position: fixed;
								justify-content: center;
						    width: 110rpx;
						    height: 110rpx;
								z-index: 999;
								border-radius: 55rpx;
								overflow: hidden;
								transform: translateY(-5px);
						}
						.item-img2{
								position: fixed;
						    width: 110rpx;
						    height: 110rpx;
								z-index: 999;
						}
            .item-name{
                font-size: 26rpx;
                color: #A3A3A3;
								position: relative;
								z-index: 1000;
            }
        }
				.tabbar-item1{
					width: 22%;
				}
    }
</style>
